package te2;

import java.util.Calendar;
import java.util.Date;

public class dateDiffDays {
	public static void main(String[] args) {
		Calendar calendar=Calendar.getInstance();
		calendar.add(Calendar.DAY_OF_MONTH, 0);
		
		Date now=new Date();
		Date date=calendar.getTime();
		
		long datediff = daysBetweenTwoDate(now,date);
		System.out.println(now+"now");
		System.out.println(date+"date");
		System.out.println(datediff+"datediff");
		System.out.println(now.getTime()+"NOW");
		System.out.println(date.getTime()+"date");
		System.out.println(now.getTime()-date.getTime());
		System.out.println((now.getTime()-date.getTime())/86400000L);		
		
	}
		
	
	public static long daysBetweenTwoDate(java.util.Date date1,
			java.util.Date date2) {
		long nDay = (date1.getTime() - date2.getTime()) / 86400000L > 0L ? (date1
				.getTime() - date2.getTime()) / 86400000L
				: (date2.getTime() - date1.getTime()) / 86400000L;
		return nDay;
	}

}

